package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.ColdStorageEquipmentEntity;
import com.jinmdz.fmis.mapper.mapper.provider.ColdStorageEquipmentProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 冷藏设备表Mapper
 *
 * @author generator
 * @date 2020-03-12 17:08
 */
public interface ColdStorageEquipmentMapper {

    /**
     * 增加ColdStorageEquipment
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @InsertProvider(type = ColdStorageEquipmentProvider.class, method = "insertColdStorageEquipment")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertColdStorageEquipment(@Param("entity") ColdStorageEquipmentEntity entity);

    /**
     * 删除ColdStorageEquipment
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Update(" update cold_storage_equipment set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForColdStorageEquipment(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改ColdStorageEquipment
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @UpdateProvider(type = ColdStorageEquipmentProvider.class, method = "updateColdStorageEquipment")
    void updateColdStorageEquipment(@Param("entity") ColdStorageEquipmentEntity entity);

    /**
     * 查询ColdStorageEquipment实体
     *
     * @param id 主键
     * @return ColdStorageEquipmentEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Select(" select id,deleted,equipment_type_code,equipment_code,equipment_describe,equipment_state,column_no,row_no,disable_state,sort,remark,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from cold_storage_equipment where id = #{id} and deleted = 0 limit 1 ")
    ColdStorageEquipmentEntity getColdStorageEquipmentById(@Param("id") Integer id);

    /**
     * 查询ColdStorageEquipment列表
     *
     * @param entity 数据实体
     * @return ColdStorageEquipmentEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @SelectProvider(type = ColdStorageEquipmentProvider.class, method = "listColdStorageEquipment")
    ArrayList<ColdStorageEquipmentEntity> listColdStorageEquipment(@Param("entity") ColdStorageEquipmentEntity entity);
}